<?php
/**
 * 注释不留名,代码随便用
 * Date: 2019/4/24
 * Time: 20:17
 */

namespace app\common\library\basicadmin;

use app\common\controller\BasicAdmin;

abstract class Logic
{
    /**
     * 数据库模型操作对象
     * @var \think\Model
     */
    protected $model;

    /**
     * 当前操作控制器引用
     * @var \library\Controller
     */
    public $controller;

    /**
     * @var \think\facade\Request
     */
    protected $request;

    public function __construct()
    {
        $this->request = request();
    }

    /**
     * 逻辑器初始化
     * @param BasicAdmin $controller
     * @return mixed
     */
    abstract public function init(BasicAdmin $controller);

    /**
     * 获取数据库查询对象
     * @param string|\think\Model $model
     * @return \think\Model
     */
    protected function buildModel($model)
    {
        return is_string($model) ? model($model) : $model;
    }
}